package com.concerneyes.health.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.concerneyes.R;
import com.concerneyes.health.healthView.HisCardView;
import com.concerneyes.health.healthView.HisDataAnalysisView;

import java.util.ArrayList;
import java.util.List;

import common.AbsBaseView;

/**
 * Created by Administrator on 2017/6/29 0029.
 */

public class HisDataAdapter extends PagerAdapter {
    private List<AbsBaseView> viewList;
    private List<String> titleList;
    private Context context;

    public HisDataAdapter(Context context,String manId) {
        this.context = context;
        titleList = new ArrayList<>();
        titleList.add(context.getResources().getString(R.string.his_optometry_data));
        titleList.add(context.getResources().getString(R.string.optometry_data_anal));
        viewList = new ArrayList<>();
        viewList.add(new HisCardView(context,manId));
        viewList.add(new HisDataAnalysisView(context,manId));
    }

    @Override
    public int getCount() {
        return viewList.size();
    }

    public AbsBaseView getView(int position) {
        return viewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewList.get(position));
    }

    @Override
    public int getItemPosition(Object object) {
        return super.getItemPosition(object);
    }

    @Override
    public AbsBaseView instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position));
        return viewList.get(position);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titleList.get(position);
    }
}
